package com.diana.serviceImpl;

import com.baomidou.mybatisplus.mapper.Condition;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.diana.common.PageUtils;
import com.diana.common.Utils;
import com.diana.entity.AlipayRecord;
import com.diana.mapper.AlipayRecordMapper;
import com.diana.service.AlipayRecordService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author anzhi
 * @since 2020-03-25
 */
@Service
public class AlipayRecordServiceImpl extends ServiceImpl<AlipayRecordMapper, AlipayRecord> implements AlipayRecordService {

    @Override
    public String getList(Map map) {
        Integer index = Utils.toInteger(map.get("index"));
        Integer size = Utils.toInteger(map.get("size"));
        Page<AlipayRecord> page = PageUtils.getPage(index, size);
        Wrapper wrapper = Condition.create().orderDesc(Collections.singleton("createTime"));
        Page<AlipayRecord> alipayRecordPage = this.selectPage(page,wrapper);
        return Utils.message("0000","获取成功",alipayRecordPage.getRecords(),alipayRecordPage.getTotal());
    }
}
